import Vue from 'vue';
import VueRouter from 'vue-router';

import home from '@/pages/home/index.vue';
import order from '@/pages/order/index.vue';
import profile from '@/pages/profile/index.vue';
import orderInit from '@/pages/order_init/index.vue';

Vue.use(VueRouter);

export default {
	install(wf) {
		const router = new VueRouter({
			// mode: 'history',
			routes: [
				{
					path: '/',
					redirect: '/order',
				},
				{
					path: '/home',
					name: 'home',
					component: home,
					meta: {
						showTabBar: true,
					},
				},
				{
					path: '/order',
					name: 'order',
					component: order,
					meta: {
						showTabBar: true,
					},
				},
				{
					path: '/profile',
					name: 'profile',
					component: profile,
					meta: {
						showTabBar: true,
					},
				},
				{
					path: '/orderInit',
					name: 'orderInit',
					component: orderInit,
				},
				{
					path: '*',
					redirect: '/profile',
				},
			],
		});

		router.afterEach((to, from) => {
			wf.getModule('reporter').report('default', 'afterEach', {
				to,
				from,
			});
		});

		wf.addModule('router', router);
	},
};
